package com.example.ut.service;

import com.example.ut.entity.StudentEntity;
import com.example.ut.mapper.StudentMapper;
import com.example.ut.repository.StudentRepository;
import com.example.ut.service.command.StudentDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
@RequiredArgsConstructor
public class StudentService {
    private final StudentRepository studentRepository;

    public boolean add(StudentDTO studentDTO) {
        StudentEntity entity = studentRepository.save(StudentMapper.INSTANCE.toEntity(studentDTO));
        return Objects.nonNull(entity.getId());
    }
}
